package com.ibeeking.found.content.b.rest.config.prop;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.Protocol;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocketFactory;
import java.io.Serializable;

/**
 * @Author ibeeking
 * Data : 17:28
 */
@Data
@ConfigurationProperties(prefix = "spring.redis")
public class RedisProperties extends JedisPoolConfig implements Serializable {
    private static final long serialVersionUID = -5924815351660074401L;

    @Value("${spring.redis.host:127.0.0.1}")
    public String host;

    @Value("${spring.redis.port:3306}")
    public Integer port;

    @Value("${spring.redis.password:123456}")
    public String password;

    public int database;

    private int connectionTimeout = Protocol.DEFAULT_TIMEOUT;

    private int timeout = Protocol.DEFAULT_TIMEOUT;

    private String clientName;

    private boolean ssl;

    private SSLSocketFactory sslSocketFactory;

    private SSLParameters sslParameters;

    private HostnameVerifier hostnameVerifier;

    /**
     * @return the redisson client
     */
    public JedisPool getJedisPool() {
        return  new JedisPool(this, host, port, timeout,password, database);
    }
}
